Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for creating, joining, and parting osu!web rooms via interop #265

Merged
merged 16 commits into from
Feb 11, 2025

Conversation

smoogipoo
Copy link
Contributor

@smoogipoo smoogipoo commented Jan 23, 2025

This server needs the ability to manage rooms for matchmaking. Because I intend to use the existing MultiplayerHub for matchmaking messages, I took a bit of a detour and made it the single endpoint for creating multiplayer rooms so that the client will no longer need to juggle two endpoints for doing certain things.

I see a future where we move playlists, daily challenge, and even the lounge to this server, but I'm taking small meaningful steps because matchmaking is the goal for now.

Sorry, something went wrong.

Avoid serialising raw details about the exception (e.g. URL) and unwrap
`{ "error": "" }` JSON responses, for instance as returned by the room
creation endpoint.

Client receives:
- `APP_DEBUG=true` -> "422: Unprocessable Entity" (HTTP status code msg)
- `APP_DEBUG=false` -> "beatmaps not found: ..." (osu!web API error msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base implementation here was pulled from osu-server-beatmap-submission with local adjustments for this server's usage (return value and HubException handling).

Comment on lines -723 to +735
await leaveRoom(state, true);
await base.CleanUpState(state);
await leaveRoom(state, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaningless change because the base implementation is empty. I just thought I'd make this consistent with other implementations, seeing as leaveRoom can throw an exception.

Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial pass.

Looks mostly quaint although I do wonder how much discussion on general direction happened in places I can't see or hear.

await runLegacyIO(HttpMethod.Delete, $"multiplayer/rooms/{roomId}/users/{userId}");
}

private class CreateRoomRequest : Room
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mild teeth pain from this inheritance but I guess anything else would probably be more annoying...

i guess this can stay for now maybe but as soon as this is touched for any reason we should probably decouple from Room ASAP

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is going to be a potential point of failure if we forget to add any changes to fields/properties going forward. But also, after careful reading it seems this isn't only adding the host user_id but also populating CurrentPlaylistItem.

@smoogipoo might be worth adding some inline commentary as to why this is required. also curious if the PlaylistItem clone is just for sanity of if there's an actual reason that it's required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but also populating CurrentPlaylistItem
might be worth adding some inline commentary as to why this is required

It isn't required. This code used to be part of the base Room model where I attempted to do everything for completed-ness. Removed.

also curious if the PlaylistItem clone

It isn't a clone, it's converting from a MultiplayerPlaylistItem to a PlaylistItem.

potential point of failure if we forget to add any changes to fields/properties going forward

Am keenly aware of this and see a path where MultiplayerRoom is serialised directly and perhaps via System.Text.Json. I didn't go that deep here to keep things simple (have to deal with enum conversion and all that JSON jankery). Once again I'll reiterate I want to keep the API and spectator models as separate as possible, so I would rather spectator doesn't deal with API models at all.

If it improves things any bit, I can move the ctor into Room. I can't remember why I decided against that in the end but it was an initial path I'd taken.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it improves things any bit, I can move the ctor into Room. I can't remember why I decided against that in the end but it was an initial path I'd taken.

As in having everything bar HostUserId populated in the base class but doing the host part here?

Copy link
Contributor Author

@smoogipoo smoogipoo Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. My thinking is it'd be harder to miss given there's a CopyFrom() method there, though I'm not sure how long that's going to remain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it for now, I'm sure we've discussed enough here no one will forget it needs updating 🙄

@bdach bdach requested a review from peppy January 24, 2025 09:06
Co-authored-by: Berkan Diler <[email protected]>
@bdach
Copy link
Collaborator

bdach commented Jan 27, 2025

Something is going to need to happen to fix the test failures here. Easiest suggestion would be to not have a static ctor in AppSettings and instead just have getters delegate directly to Environment.GetEnvironmentVariable().

@peppy
Copy link
Member

peppy commented Feb 10, 2025

@smoogipoo I made some naming and minor code structure changes, please check you're okay with them.

@smoogipoo
Copy link
Contributor Author

Your changes look fine.

@peppy peppy merged commit 9716e12 into ppy:master Feb 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants